package com.apes.scm.stock.safetyStock.model;

import com.alibaba.fastjson.annotation.JSONField;
import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.DateUtil;
import com.apes.scm.masterdata.stock.model.Location;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

@Entity
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@EntityListeners(DefaultPersistListener.class)
@Table(name = StockGapDistributionInfo.CONST_TABLE_NAME,
        indexes = {@Index(name = "idx_gap_distribut_f_location", columnList = "f_location_id"), @Index(name = "idx_gap_distribut_location", columnList = "location_id")})
public class StockGapDistributionInfo extends BaseModel {
    public static final  String CONST_TABLE_NAME = "Stock_Gap_Distribution_Info";

    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "安全库存缺口分配信息")
    private String id;

    @Comment("父仓库库区")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "f_location_id", referencedColumnName = "id", nullable = false)
    private Location FLocation;

    @Comment("缺货仓库库区")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "location_id", referencedColumnName = "id", nullable = false)
    private Location location;

    @Comment("执行日期")
    @JSONField(format = DateUtil.SHOW_DATETIME_FORMAT)
    @Column(name = "execute_Data")
    private Date executeData;

}
